package com.lijie.bs_recruit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lijie.bs_recruit.Util.WrapperUtil;
import com.lijie.bs_recruit.mapper.JobfairMapper;
import com.lijie.bs_recruit.model.Jobfair;
import com.lijie.bs_recruit.service.JobfairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lijie
 * @since 2021-04-07
 */
@Service
public class JobfairServiceImpl extends ServiceImpl<JobfairMapper, Jobfair> implements JobfairService {

    @Autowired
    WrapperUtil wrapperUtil;


    @Override
    public Boolean addJobFair(Jobfair jobfair) {
        int insert = baseMapper.insert(jobfair);
        return insert>0;
    }


    @Override
    public PageInfo<Jobfair> selectJobFair(Integer pageIndex, Jobfair jobfair) {
        if(pageIndex == null) pageIndex = 1;
        QueryWrapper<Jobfair> positionQueryWrapper = wrapperUtil.wrapperJobfair(jobfair);
        PageHelper.startPage(pageIndex,6);
        List<Jobfair> positions = baseMapper.selectList(positionQueryWrapper);
        PageInfo<Jobfair> pageInfo = new PageInfo<>(positions);
        return pageInfo;
    }

    @Override
    public Jobfair selJobFair(Integer jobfairId) {
        Jobfair jobfair = baseMapper.selectById(jobfairId);
        return jobfair;
    }

    @Override
    public Boolean updateJobFair(Jobfair jobfair) {
        jobfair.setUpdateTime(null);//去除更新时间，让数据库自动添加
        jobfair.setCreateTime(null);//去除更新时间，让数据库自动添加
        int i = baseMapper.updateById(jobfair);
        return i>0;

    }


}
